package com.lzy.common;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
public class CommonEntity implements Serializable {
    private static final long serialVersionUID=1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_UUID)
    @JsonProperty(access = JsonProperty.Access.READ_WRITE)
    private String id;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT,value ="create_time")
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime createTime;
 
    /**
     * 最后更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE,value ="update_time")
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime updateTime;
 
    /**
     * 最新版本
     */
    @TableField(fill = FieldFill.INSERT_UPDATE, update = "%s+1",value = "version")
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @Version
    private Integer version;
 
    /**
     * 删除标记(0-否，1-是)
     */
    @TableLogic
    @TableField(fill = FieldFill.INSERT,value = "del_flag")
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private Boolean delFlag;
 
}